﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace CheckersClientApplication
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        SplashScreen splashscreen = new SplashScreen("/Resources/loadingimage.jpg");
        public MainWindow()
        {
            InitializeComponent();
        }

        private void loginBtn_Click(object sender, RoutedEventArgs e)
        {
            try
            {

                LoginScreen screen = new LoginScreen();
                screen.Show();
                this.Hide();
            }
            catch(Exception exp)
            {
                MessageBox.Show(exp.Message);
            }
            
        }

        private void signUpBtn_Click(object sender, RoutedEventArgs e)
        {
            try
            {

                splashscreen.Show(false, true);
                var objclsPlayer = new LoginServiceReference.clsPlayer()
                {
                    PlayerName = playerNameTxt.Text,
                    PlayerUserName = playerUsernameTxt.Text,
                    PlayerPassword = playerPasswordTxt.Password
                };

                LoginServiceReference.LoginServiceClient client = new LoginServiceReference.LoginServiceClient();

                objclsPlayer = client.Singup(objclsPlayer);
                splashscreen.Close(System.TimeSpan.Zero);
                //MessageBox.Show(objclsPlayer.PlayerId.ToString());

                GameRoomList list = new GameRoomList(objclsPlayer);
                list.Show();
                this.Hide();
            }
            
            catch(Exception exp)
            {
                MessageBox.Show(exp.Message);
            }
            
        }
    }
}
